import Vue from 'vue';
import store from './store';
import 'vant/lib/index.css';
import FastClick from 'fastclick';
import { Toast, Dialog, Loading } from 'vant';
import VueClipboard from 'vue-clipboard2';
import Vconsole from 'vconsole';

// if (process.env.VUE_APP_ENV !== 'production') {
new Vconsole();
// }

Vue.use(VueClipboard);
Vue.prototype.$Toast = Toast;
Vue.use(Dialog);
Vue.use(Loading);

import 'animate.css';
import App from './app.vue';
import router from './router';

Vue.config.silent = true;
Vue.config.productionTip = false;

new Vue({
    router,
    store,
    render: h => h(App),
}).$mount('#app');

if ('addEventListener' in document) {
    document.addEventListener(
        'DOMContentLoaded',
        function () {
            FastClick.attach(document.body);
        },
        false
    );
}

FastClick.prototype.focus = function (targetElement) {
    let length;
    if (
        targetElement.setSelectionRange &&
        targetElement.type.indexOf('date') !== 0 &&
        targetElement.type !== 'time' &&
        targetElement.type !== 'month'
    ) {
        length = targetElement.value.length;
        targetElement.focus();
        targetElement.setSelectionRange(length, length);
    } else {
        targetElement.focus();
    }
};
